******************************************************************************
	*** Figure 5 ***
******************************************************************************
	
	//Use main data
	use "${maindta}", clear

	*Kernel densities
	foreach q in 10 25 50 75 90  {
		rifhdreg firm_score_est [pw=wt], rif(q(`q'))
		global l`q'=_b[_cons]
		rifhdreg score_centered [pw=wt_rs], rif(q(`q'))
		global cl`q'=_b[_cons]
	}
	rifhdreg firm_score_est [pw=wt], rif(std)
	global rif_sd=_b[_cons]
	rifhdreg score_centered [pw=wt_rs], rif(std)
	global crif_sd=_b[_cons]

	kdensity firm_score_est [aw=wt] , xlab(,nogrid labsize(large)) ylab(,nogrid labsize(large)) note("") title(" " , size(large)) ytitle("") xtitle("")  clwidth(thick) xline($l10 $l25 $l75 $l90, lcolor(gs7%50)) xline($l50, lcolor(gs4) lwidth(thick)) text(.01 $l50 "Median", box bcolor(white) fcolor(white) lcolor(white) lwidth(vvthick))  xsize(11) ysize(5)


	preserve
	collapse (mean) firm_score_est vae_rs CPIscore2017  [pw=wt], by(country)
	su vae_rs, d
	global v25=`r(p25)'
	global v75=`r(p75)'

	su CPIscore2017, d
	global c25=`r(p25)'
	global c75=`r(p75)'

	restore 


	*Kernel densities
	foreach q in 10 25 50 75 90  {
		rifhdreg firm_score_est [pw=wt] if vae_rs>=$v75, rif(q(`q'))
		global v`q'_hi=_b[_cons]
		
		rifhdreg firm_score_est [pw=wt] if vae_rs<=$v25, rif(q(`q'))
		global v`q'_lo=_b[_cons]
		
		rifhdreg firm_score_est [pw=wt] if CPIscore2017>=$c75, rif(q(`q'))
		global c`q'_hi=_b[_cons]
		
		rifhdreg firm_score_est [pw=wt] if CPIscore2017<=$c25, rif(q(`q'))
		global c`q'_lo=_b[_cons]
	}


	*Kernel densities
	foreach q in 10 25 50 75 90  {
		rifhdreg score_centered [pw=wt_rs] if vae_rs>=$v75, rif(q(`q'))
		global v`q'_hic=_b[_cons]
		
		rifhdreg score_centered [pw=wt_rs] if vae_rs<=$v25, rif(q(`q'))
		global v`q'_loc=_b[_cons]
		
		rifhdreg score_centered [pw=wt_rs] if CPIscore2017>=$c75, rif(q(`q'))
		global c`q'_hic=_b[_cons]
		
		rifhdreg score_centered [pw=wt_rs] if CPIscore2017<=$c25, rif(q(`q'))
		global c`q'_loc=_b[_cons]
	}


	//high vs. low V&A
	cap drop y1 x1 x2
	gen y1=.07
	gen x1=68
	gen x2=33
	twoway kdensity firm_score_est [aw=wt] if vae_rs>=$v75, lcolor(green%75) lwidth(thick) || kdensity firm_score_est [aw=wt] if vae_rs<=$v25, lcolor(red%75) lwidth(thick)  xlab(,nogrid labsize(large)) ylab(,nogrid labsize(large)) note("") title(" " , size(large)) ytitle("") xtitle("")  clwidth(thick) xline($v25_hi $v75_hi, lcolor(green%25) lwidth(thick) lpattern(solid))  xline($v25_lo $v75_lo, lcolor(red%25) lwidth(thick) lpattern(dash)) xsize(6) ysize(3) legend(off) text(.105 $v25_hi "25{sup:th}", color(green%50)) text(.105 $v25_lo "25{sup:th}", color(red%50)) text(.025 45 "High Voice " "& Accountability" "(Top quartile of economies)", color(green%50)) text(.025 85 "Low Voice " "& Accountability" "(Bottom quartile of economies)", color(red%50)) text(.105 $v75_hi "75{sup:th}", color(green%50)) text(.105 $v75_lo "75{sup:th}", color(red%50)) ylabel(0 .05 .1) || pcarrow y1 x1 y1 x2, text(.08 50 "Difference" "in 75{sup:th}" "Percentiles") xtitle("Political Influence (0 to 100)")

	graph export "${outfigures}\Figure5.pdf", replace